﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Globalization;
using umbraco.cms.businesslogic.language;
using umbraco.cms.businesslogic.web;

namespace UmbSearch2.UserControls
{
	public partial class LanguagePicker : System.Web.UI.UserControl, umbraco.editorControls.userControlGrapper.IUsercontrolDataEditor
	{
		private string umbracoValue;
		
		protected void Page_Load(object sender, EventArgs e)
		{
			// first time loading
			if (!IsPostBack)
			{
				Domain[] domains = Domain.GetDomainsById(int.Parse(Request["id"]));
				if (domains.Length > 0)
				{
					lblLanguage.Text = domains[0].Language.CultureAlias;
				}
			}

			// after saving
			if(IsPostBack)
			{

			}
		}

		private bool languageExists(string culture)
		{
			foreach (Language l in m_langs)
			{
				if (l.CultureAlias == culture)
					return true;
			}
			return false;
		}

		#region IUsercontrolDataEditor Members

		public object value
		{
			get
			{
				return umbracoValue;
			}
			set
			{
				umbracoValue = value.ToString();
			}
		}

		#endregion
	}
}